﻿// ***********************************************************************
// Assembly         : TSharp.Core
// Author           : tangjingbo
// Created          : 06-03-2013
//
// Last Modified By : tangjingbo
// Last Modified On : 06-03-2013
// ***********************************************************************
// <copyright file="Interface1.cs" company="Extendsoft">
//     Copyright (c) Extendsoft. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TSharp.Core.Authorization.Resources;

namespace TSharp.Core.Authorization.Control
{
    /// <summary>
    /// 权限的管理类
    /// </summary>
    public interface IControlManager
    {
        /// <summary>
        /// 获取指定参与者对指定资源或者资源组的操作权限[不包含继承的权限]
        /// </summary>
        /// <param name="actorId">The actor key.</param>
        /// <param name="resourceId">The resource key.</param>
        /// <returns>String.</returns>
        int[] GetControlData(Guid actorId, Guid resourceId);

        /// <summary>
        /// 获取指定参与者对指定资源或者资源组的操作权限[包含继承的权限]
        /// </summary>
        /// <param name="actorId">The actor key.</param>
        /// <param name="resourceId">The resource key.</param>
        /// <param name="getInheritedOnly">if set to <c>true</c> [get inherited only].</param>
        /// <returns>String.</returns>
        int[] GetControlData(Guid actorId, Guid resourceId, bool getInheritedOnly);

        /// <summary>
        /// 获取指定参与者相关的所有资源的操作权限列表
        /// </summary>
        /// <param name="actorId">The actor key.</param>
        List<ResourcePermissionKeyValue> GetControlDatasByActor(Guid actorId);

        /// <summary>
        /// 获取所有参与者对指定资源的操作权限列表，对初始化的资源类别有效
        /// </summary>
        /// <param name="resourceId">The res key.</param>
        List<ResourcePermissionKeyValue> GetControlDatasByResource(Guid resourceId);

        /// <summary>
        /// 获取多个参与者对多个资源或者多个资源组的操作权限列表
        /// </summary>
        /// <param name="actorsId">The actors key.</param>
        /// <param name="resourcesId">The resources key.</param>
        /// <param name="operationsCode">The control strings.</param>
        void GetControlDatas(List<Guid> actorsId, List<Guid> resourcesId, List<int> operationsCode);

        /// <summary>
        /// 获取多个参与者拥有指定操作权限的资源或者资源组代码列表
        /// </summary>
        /// <param name="actorsId">The actors key.</param>
        /// <param name="operationCode">The operation ID.</param>
        List<Guid> GetAllowActResources(List<Guid> actorsId, int operationCode);

        /// <summary>
        /// 获取多个参与者禁止指定操作权限的资源或者资源组代码列表
        /// </summary>
        /// <param name="actorsId">The actors key.</param>
        /// <param name="operationCode">The operation ID.</param>
        /// <param name="resourcesId">The resources key.</param>
        void GetForbidActResources(List<Guid> actorsId, int operationCode, List<Guid> resourcesId);

        /// <summary>
        /// 添加或者更新权限
        /// </summary>
        bool AddOrEditControlData(Guid actorId, Guid resourceId, params int[] operationsCode);

        /// <summary>
        /// 删除指定参与者对指定资源的权限
        /// </summary>
        bool RemoveControlData(Guid actorId, Guid resourceId);

        /// <summary>
        /// 删除指定参与者的所有权限
        /// </summary>
        bool RemoveActorControlDatas(Guid actorId);

        /// <summary>
        /// 删除指定资源的所有权限
        /// </summary>
        bool RemoveResourceControlDatas(Guid resourceId);

        ///// <summary>
        ///// 合并权码，用于数据库存储
        ///// </summary>
        //int CombinePermissionCode(int[] permissionCodeArray);

        ///// <summary>
        ///// 拆分权码，用于权限编辑
        ///// </summary>
        //int[] SplitPermissionCode(int permissionCodeArray);
    }
}
